<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
    <link href="/jw/Public/css/app/select.css" type="text/css" rel="stylesheet">
    <script src="/jw/Public/js/jquery.js"></script>
</head>
<!--查询主页面-->
<body>
    <div class="topbar" id="topbar">
        <div class="lefticon"></div>
        <div class="center">
            <div class="text">学生基本信息查询</div>
        </div>
        <div class="rightnull"></div>
    </div>
    <div class="topbar topbarnonefix" id="topbar2">
        <div class="lefticon"></div>
        <div class="center">
            <div class="text">查询</div>
        </div>
        <div class="rightnull"></div>
    </div>

    <form name='form1'id="form1" action="<?php echo U('Search/index');?>" method="post">
        <div class="select">
            <div class="nulldiv"></div>
            <div class="selectdiv" id="sel">
                <div class="lefticon"><img src="/jw/Public/img/app/select/glass.png" id="glass"></div>
                <input id='myinput' placeholder="输入关键词" name="key" onclick="hidetopbar()" value=<?php echo ($keyword); ?>>
                <!--<input placeholder="输入关键词">-->
            </div>
            <div class="centernulldiv" id="centernull"></div>
            <div class="rightbutton" id="cancel" onclick="showtopbar()">
                取消
            </div>
            <div class="nulldiv"></div>
        </div>
    </form>
    <div id="input2" style="display: none"><?php echo ($keyword); ?></div>

    <?php if(count($history)!=0): ?><div class="sel_status" id="sel_result">

            <?php if(is_array($history)): foreach($history as $key=>$vo): ?><div class="first">
                    <div class="left"><img src="/jw/Public/img/app/select/glass.png"> </div>
                    <div class="right"><?php echo ($vo); ?></div>
                </div><?php endforeach; endif; ?>

        </div><?php endif; ?>


    <!--未搜索（没给input传值时）不显示搜索到的条目数量-->
    <?php if($count!=null): ?><div class="number" id="number">
            <div class="left"></div>
            <div class="txt">搜索结果：<?php echo ($count); ?>条</div>
        </div><?php endif; ?>

    <!--当输入了关键字却没有搜到相关信息时-->
    <?php if(($count!=null)&&($count==0)): ?><div class="wrongdiv">
            <div class="leftImage"><img src="/jw/Public/img/error.png"></div>
            <div class="right">
                <div class="line">  不好意思小主,</div>
                <div class="line">木有查到信息哦</div>
            </div>
        </div><?php endif; ?>

    <?php if($listInf!=null): ?><div class="list" id="list">
            <?php if(is_array($listInf)): foreach($listInf as $key=>$vo): ?><a href="<?php echo U('Inform/index',array('sno'=>$vo['学号'],'age'=>$vo['年纪']));?>">
                    <div class="line">
                        <div class="null"></div>
                        <div class="left"><img src="<?php echo ($vo['图片']); ?>"/></div>
                        <div class="center"></div>
                        <div class="right">
                            <div class="firline"><?php echo ($vo['姓名']); ?> <?php echo ($vo['学号']); ?></div>
                            <div class="secline"><?php echo ($vo['性别']); ?> <?php echo ($vo['年纪']); ?>岁 <?php echo ($vo['籍贯']); ?> <?php echo (substr($vo['出生日期'],0,10)); ?></div>
                            <div class="thiline"><?php echo ($vo['院系名称']); ?> <?php echo ($vo['班级名称']); ?></div>
                        </div>
                        <div class="null"></div>
                    </div>
                </a><?php endforeach; endif; ?>
        </div><?php endif; ?>

    <?php if($count > 6): ?><div class="moreinfo" id="moreinfo" onclick="more()">
            <div class="text" id="moretext">加载更多...</div>
        </div><?php endif; ?>
</body>
</html>
<script src="/jw/Public/js/app/jquery.js"></script>
<script src="/jw/Public/js/app/select.js"></script>
<script>
    $(document).ready(function(){
        //将历史记录那个整个大框都监听起来，只要点击了其中一条，就将该条的内容写到input里面
        $(".sel_status .first .right").click(function(){
            var a=$(this).html();
            $("#myinput").val(a);//将历史记录的值写进input
            document.getElementById("myinput").focus();//input获取焦点

            document.getElementById('sel_result').style.display='none';//历史搜索关键词  隐藏
            document.getElementById('number').style.display='none';
        })
    });

    var page = 1;
    var num = 6; //刷新显示条数
    function more(){
        var key=document.getElementById('input2').innerText;
        $.post("http://192.168.1.66/jw/app-search-index",{page:page,key:key,num:num}, function (data,status) {
            alert(data);
            $.each(data.list, function (index, item) {
                var sno=item.学号;
                $('#list').append("<a href='http://192.168.1.66/jw/app-inform-index?sno="+item.学号+"&age="+item.年纪+"'><div class='line'> <div class='null'></div> <div class='left'><img src='"+item.图片+"'/></div> <div class='center'></div> <div class='right'> <div class='firline'>"+item.姓名+" "+item.学号+"</div> <div class='secline'>"+item.性别+" "+item.年纪+"岁 "+item.籍贯+" "+item.出生日期+"</div> <div class='thiline'>"+item.院系名称+" "+item.班级名称+"</div> </div> <div class='null'></div> </div></a>");
            });
            if(data.over=='true'){
                $("#moretext").html("没有内容了");
            }
            page++;
        });
    }
</script>